<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>订舱反馈 | </title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="font/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <!--<link href="css/nprogress.css" rel="stylesheet">-->

    <!-- Custom Theme Style -->
    <link href="css/custom.min.css" rel="stylesheet">
</head>

<body class="nav-md">
<div class="container body">
    <div class="main_container">
        <div id="head">

        </div>
        <!-- /top navigation -->

        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">
                <div class="page-title">
                    <div class="title_left">
                        <h3>订舱反馈</h3>
                    </div>


                </div>
                <div class="clearfix"></div>

                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">

                            <div class="x_content">

                                <form class="form-horizontal form-label-left" novalidate>


                                    <span class="section">订舱反馈</span>

                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="bookingReqNo">订舱号 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="bookingReqNo" style="width: 300px" class="form-control col-md-7 col-xs-12"  placeholder="请填写订舱号"  type="text">
                                            <span id="bookingReqNoError" style="margin-left: 20px;line-height: 34px;color: red;display: none"></span>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="yconId">预排柜号 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="yconId" style="width: 300px" class="form-control col-md-7 col-xs-12"  placeholder="请填写预排柜号"  type="number">
                                            <span id="yconIdError" style="margin-left: 20px;line-height: 34px;color: red;display: none"></span>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="sono">SONO<span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="sono" style="width: 300px" class="form-control col-md-7 col-xs-12" placeholder="请填写提单号" data-validate-length-range="6" data-validate-words="2" type="number">
                                            <span id="sonoError" style="margin-left: 20px;line-height: 34px;color: red;display: none"></span>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="shipsname">船名/机名<span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" style="width: 300px" id="shipsname" name="confirm_email" data-validate-linked="email" placeholder="请填写船名/机名" class="form-control col-md-7 col-xs-12">
                                            <span id="shipsnameError" style="margin-left: 20px;line-height: 34px;color: red;display: none"></span>
                                        </div>
                                    </div>

                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="shipscount">航次/航班
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" style="width: 300px" id="shipscount" placeholder="请填写航次/航班" class="form-control col-md-7 col-xs-12">
                                            <span id="shipscountError" style="margin-left: 20px;line-height: 34px;color: red;display: none"></span>
                                        </div>
                                    </div>
                                    
                                   
                                    <div class="item form-group">
                                        <label for="etd" class="control-label col-md-3 col-sm-3 col-xs-12">ETD(预计离开时间)</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="etd" style="width: 300px" type="date" name="password2"  data-validate-linked="password" class="form-control col-md-7 col-xs-12">
                                            <span id="etdError" style="margin-left: 20px;line-height: 34px;color: red;display: none"></span>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="eta">ETA(预计到达时间)
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="date" style="width: 300px" id="eta"  data-validate-length-range="8,20" class="form-control col-md-7 col-xs-12">
                                            <span id="etaError" style="margin-left: 20px;line-height: 34px;color: red;display: none"></span>
                                        </div>
                                    </div>
                                    <div class="item form-group" >
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="ycontype">箱&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;型
                                        </label>
                                        <div class=" col-xs-9" id="email3">
                                            <select id="ycontype" style="height: 30px;width: 300px;padding-left: 10px" >
                                                <option value="0">---请选择---</option>
                                                <option value="678">678</option>
                                                <option value="397">397</option>
                                                <option value="421">421</option>
                                            </select>
                                            <span id="ycontypeError" style="margin-left: 20px;line-height: 34px;color: red;display: none"></span>
                                        </div>
                                    </div>
                                    <div class="item form-group" >
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="yconamount">箱&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;量
                                        </label>
                                        <div class=" col-xs-9" id="email4">
                                            <select id="yconamount" style="height: 30px;width: 300px;padding-left: 10px" >
                                                <option>---请选择---</option>
                                                <option value="40">40</option>
                                                <option value="60">60</option>
                                                <option value="80">80</option>
                                            </select>
                                            <span id="yconamountError" style="margin-left: 20px;line-height: 34px;color: red;display: none"></span>
                                        </div>
                                    </div>
                                    <div class="item form-group" >
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="yconsize">尺&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;寸
                                        </label>
                                        <div class=" col-xs-9" id="email5">
                                            <select id="yconsize" style="height: 30px;width: 300px;padding-left: 10px" >
                                                <option>---请选择---</option>
                                                <option>58</option>
                                                <option>47</option>
                                                <option>69</option>
                                            </select>
                                            <span id="yconsizeError" style="margin-left: 20px;line-height: 34px;color: red;display: none"></span>
                                        </div>
                                    </div>
                                    
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" >截关时间
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="date" id="closingTime" style="width: 300px" data-validate-length-range="8,20" class="form-control col-md-7 col-xs-12">
                                            <span id="closingTimeError" style="margin-left: 20px;line-height: 34px;color: red;display: none"></span>
                                        </div>
                                    </div>
                                  

                                    <div class="ln_solid"></div>
                                    <div class="form-group">
                                        <div class="col-md-6 col-md-offset-3">
                                            <a href="javascript:;" id="send"  class="btn btn-success">保存</a>
											 <a href="javascript:;" class="btn btn-primary hui" >返回</a>

                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- /page content -->

        <!-- footer content -->
        <footer>
            <div class="pull-right">
                Gentelella - Bootstrap Admin Template by <a href="https://colorlib.com">Colorlib</a>
            </div>
            <div class="clearfix"></div>
        </footer>
        <!-- /footer content -->
    </div>
</div>

<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="js/fastclick.js"></script>
<!-- NProgress -->
<script src="js/nprogress.js"></script>
<!-- validator -->
<script src="js/validator.js"></script>

<!-- Custom Theme Scripts -->


<!-- validator -->
<script>
    var $token=window.sessionStorage.getItem('token');
    var url = window.location.href;
    var termsId = url.split("=")[1];

    $("#bookingReqNo").blur(function() {
        if ($(this).val()==""  ){
            $("#bookingReqNoError").show();
            $("#bookingReqNoError").html("请输入订舱号");
        } else {
            $("#bookingReqNoError").hide();
        }
    });
    $("#yconId").blur(function() {
        var $pattern = /^\d{3,5}$/;
        if ($(this).val()==""){
            $("#yconIdError").show();
            $("#yconIdError").html("请输入预排柜号");
        }else if ($(this).val().length>5 || $(this).val().length<3){
            $("#yconIdError").show();
            $("#yconIdError").html("请输入正确的预排柜号");
        }else {
            $("#yconIdError").hide();
        }
    });
    $("#sono").blur(function() {
        if ($(this).val()==""){
            $("#sonoError").show();
            $("#sonoError").html("请输入提单号");
        }else if ($(this).val().length>5 || $(this).val().length<3){
            $("#sonoError").show();
            $("#sonoError").html("请输入正确的提单号");
        }else {
            $("#sonoError").hide();
        }
    });
    $("#shipsname").blur(function() {
        if ($(this).val()==""){
            $("#shipsnameError").show();
            $("#shipsnameError").html("请输入船名/机名");
        }else {
            $("#shipsnameError").hide();
        }
    });
    $("#shipscount").blur(function() {
        if ($(this).val()==""){
            $("#shipscountError").show();
            $("#shipscountError").html("请输入航次/航班");
        }else {
            $("#shipscountError").hide();
        }
    });
    $("#etd").blur(function() {
        if ($(this).val()==""){
            $("#etdError").show();
            $("#etdError").html("请选择离开时间");
        }else {
            $("#etdError").hide();
        }
    });
    $("#eta").blur(function() {
        if ($(this).val()==""){
            $("#etaError").show();
            $("#etaError").html("请选择到达时间");
        }else {
            $("#etaError").hide();
        }
    });
    $("#ycontype").blur(function() {
        if ($(this).val()==0){
            $("#ycontypeError").show();
            $("#ycontypeError").html("请选择箱型");
        }else {
            $("#ycontypeError").hide();
        }
    });
    $("#yconamount").blur(function() {
        if ($(this).val()==0){
            $("#yconamountError").show();
            $("#yconamountError").html("请选择箱量");
        }else {
            $("#yconamountError").hide();
        }
    });
    $("#yconsize").blur(function() {
        if ($(this).val()==0){
            $("#yconsizeError").show();
            $("#yconsizeError").html("请选择尺寸");
        }else {
            $("#yconsizeError").hide();
        }
    });
    $("#closingTime").blur(function() {
        if ($(this).val()==0){
            $("#closingTimeError").show();
            $("#closingTimeError").html("请选择截关时间");
        }else {
            $("#closingTimeError").hide();
        }
    });



    //确认反馈订舱，新增预排柜

    $("#send").click(function() {
        var $bookingReqNo =$("#bookingReqNo").val();
        var $yconId =$("#yconId").val();
        var $sono =$("#sono").val();
        var $shipsname =$("#shipsname").val();
        var $shipscount  =$("#shipscount").val();
        var $etd  =$("#eta").val();
        var $eta  =$("#eta").val();
        var $ycontype =$("#ycontype").val();
        var $yconamount  =$("#yconamount").val();
        var $yconsize  =$("#yconsize").val();
        var $closingTime =$("#closingTime").val();
        var $pattern = /^\d{3,5}$/;
        if ($bookingReqNo==""){
            $("#bookingReqNoError").show();
            $("#bookingReqNoError").html("请输入订舱号");
            return;
        }else if ($yconId=="" || !($pattern.test($yconId))){
            $("#yconIdError").show();
            $("#yconIdError").html("请输入正确的预排柜号");
            return;
        }else if ($sono=="" || !($pattern.test($sono))){
            $("#sonoError").show();
            $("#sonoError").html("请输入正确的提单号");
            return;
        }else if ($shipsname==""){
            $("#shipsnameError").show();
            $("#shipsnameError").html("请输入船名/机名");
            return;
        }else if ($shipscount==""){
            $("#shipscountError").show();
            $("#shipscountError").html("请输入航次/航班");
            return;
        }else if ($etd==""){
            $("#etdError").show();
            $("#etdError").html("请选择离开时间");
            return;
        }else if ($eta==""){
            $("#etaError").show();
            $("#etaError").html("请选择到达时间");
            return;
        }else if ($ycontype==0){
            $("#ycontypeError").show();
            $("#ycontypeError").html("请选择箱型");
            return;
        }else if ($yconamount==0){
            $("#yconamountError").show();
            $("#yconamountError").html("请选择箱量");
            return;
        }else if ($yconsize==0){
            $("#yconsizeError").show();
            $("#yconsizeError").html("请选择尺寸");
            return;
        }else if ($closingTime==""){
            $("#closingTimeError").show();
            $("#closingTimeError").html("请选择截关时间");
            return;
        }else {
            $.ajax({
                type:"post",
                xhrFields:{withCredentials:true},
                url:"http://localhost:8081/booking/addYcon",
                dataType:"json",
                data:{"orderNumber":termsId,"bookingReqNo":$bookingReqNo,"yconId":$yconId,"sono":$sono,"shipsname":$shipsname,
                    "shipscount":$shipscount,"ycontype":$ycontype,"yconamount":$yconamount,"yconsize":$yconsize,
                    "etds":$etd, "etas":$eta,"closingTimes":$closingTime,"token":$token},
                success:function (data) {
                    if(data.message=="no"){
                        alert("无法反馈");
                        return;
                    }else if(data.message=="toShip"){
                        window.location.href='booking_order.html';
                    }else{
                        window.location.href='air_order.html';
                    }

                },
                error:function(){
                    alert("异常");
                }
            });
        }

    });

    $(document).on("click",".hui",function(){
        $.ajax({
            type:"post",
            xhrFields:{withCredentials:true},
            url:"http://localhost:8081/booking/checkOrderType",
            dataType:"json",
            data:{"orderNumber":termsId,"token":$token},
            success:function (data) {
                if(data.message=="no"){
                    alert("无法反馈");
                    return;
                }else if(data.message=="toShip"){
                    window.location.href='booking_order.html';
                }else{
                    window.location.href='air_order.html';
                }

            },
            error:function(){
                alert("异常");
            }
        });


    });




    // initialize the validator function
    validator.message.date = 'not a real date';

    // validate a field on "blur" event, a 'select' on 'change' event & a '.reuired' classed multifield on 'keyup':
    $('form')
        .on('blur', 'input[required], input.optional, select.required', validator.checkField)
        .on('change', 'select.required', validator.checkField)
        .on('keypress', 'input[required][pattern]', validator.keypress);

    $('.multi.required').on('keyup blur', 'input', function() {
        validator.checkField.apply($(this).siblings().last()[0]);
    });

    $('form').submit(function(e) {
        e.preventDefault();
        var submit = true;

        // evaluate the form using generic validaing
        if (!validator.checkAll($(this))) {
            submit = false;
        }

        if (submit)
            this.submit();

        return false;
    });
     $('#head').load("head.html");
   
</script>
<!-- /validator -->
</body>
</html>